﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;

namespace CSConsoleTest
{
    class TestForm : BaseConsoleTest
    {
        public void printDescription()
        {
            Console.WriteLine("--- Forms ---");
        }

        public void doTest()
        {
            //Message filtering test
            //Application.AddMessageFilter(new MsgFilter());

            //Form
            MyForm myForm = new MyForm();
            myForm.Width = 500;
            myForm.Height = 300;
            myForm.BackColor = Color.FromArgb(255, 0, 0, 255);
            myForm.Opacity = 0.8; // 0.00 ~ 1.00
            myForm.Text = "FormTest";

            //Controls
            Button btnTest = new Button();
            btnTest.Text = "TestButton";
            btnTest.Left = 10;
            btnTest.Top = 10;
            btnTest.Click += (object aSender, EventArgs aEventArgs) => {
                MessageBox.Show("Test button clicked");
            };
            myForm.Controls.Add(btnTest);

            Application.Run(myForm);
        }

    }

    class MsgFilter : IMessageFilter
    {
        public bool PreFilterMessage(ref Message msg)
        {
            switch (msg.Msg)
            {
                case 0x0F:
                case 0x200:
                case 0x113:
                    return false;
                case 0x201:
                    Application.Exit();
                    return true;
                default:
                    Console.WriteLine("{0} : {1}", msg.ToString(), msg.Msg);
                    return true;
            }

        }
    }
}
